<template>
  <div class="purchase-info innerPageTable-out-flex">
    <search-form
      :form-data="formData"
      @search="searchHandle"
      @reset="resetHandle"
      :label-width="120"
    ></search-form>

    <InnerPageTable ref="listTable" :config="pageTableConfig">
      <div slot="table-bar">
        <Button v-show="false" @click.native="selectUpload(true, 'purchaser/update')" size="small">全部上报</Button>
        <Button v-show="false" @click.native="selectUpload(false, 'purchaser/update')" :disabled="btnDisabled">勾选上报</Button>
        <Button @click.native="downHandle('01')" v-if='showCurrentBtn'>模板下载</Button>
        <Button @click.native="exportHandle('purchaser/export')" :disabled="btnDisabled">导出</Button>
        <Button @click.native="importHandle" v-if='showCurrentBtn'>导入</Button>
        <Button @click.native="readWareHandle" :disabled="!selectData.length" v-if='currentRole.split(",").includes("1")'>已阅警告</Button>
        <input type="file" ref="selectFile" style="display:none" @change="importData($event, 'purchaser/import')" />
<!--        <Button v-show="false"></Button>-->
      </div>
    </InnerPageTable>
  </div>
</template>
<script>
import SearchForm from "@/components/common/SearchForm"
import {configForm, generateColumns, detailField} from './js/purchase-constant'
import {superviseInfoAPI} from '@/api/superviseInfo'
import detailPage from "@/components/detailInfo";
import { mixin } from "@/views/superviseInfo/mix/mixin";
import { stateHandleMix } from "@/views/superviseInfo/mix/stateHandleMix";

export default {
  name: 'purchaseInfo',
  components: {
    searchForm: SearchForm
  },
  mixins: [mixin, stateHandleMix],
  computed: {
    searchData() {
      return configForm.bind(this)()
    }
  },
  data () {
    return {
      // formData: configForm,
      pageTableConfig: {
        loadDataFn: this.getTableList,
        columns: generateColumns.bind(this)(),
        autoFirst: true,
        initParam: {
          "crsrm_bidding_id": "",
          "crsrm_bidding_name": "",
          "crsrm_data_source": "",
          "crsrm_purchaser_name": "",
          "crsrm_purchaser_sbu": "",
          "crsrm_purchaser_type": "",
          "crsrm_state": "",
          "endDate": 0,
          "push_state": "",
          "resultState": [],
          "startDate": 0
        },
        // selectionAreaItem: { key: "id", title: "id" },
        allSelection: [],
        onSelectionChange: this.selectHandle,
      },
    }
  },
  mounted() {
    console.log(this.crsrm_pur_data_source,'wwww');
  },
  methods: {
    getTableList(tableObj) {
      let { responseProcess, initParam, param } = tableObj;
      const params = {
        ...param,
        ...initParam
      };
      superviseInfoAPI.purchaseList(params).then(res => {
        responseProcess(res.data);
      });
    },
    detailHandle(id) {
      let detailInfo = {}
      this.$Spin.show()
      superviseInfoAPI.purchaseDetail({ id: id }).then(res => {
        detailInfo = res.data
        this.$Spin.hide()
        new this.$sidelipPage(detailPage, { props: { detailInfo, detailField, title: '采购信息详情', listId: id }, isNav: false });
      })
    },
  }
}
</script>
